<template>
	<view>
		<search :placeholder="$t('homepage.AccessoryManagement.storageCode')" />
		<!-- 搜索无记录 -->
		<zy-empty v-if="storagePositionInfoList.length==0"></zy-empty>
		<!-- 查询表单 -->
		<storagePositionInfoList :storagePositionInfoList="storagePositionInfoList" v-else></storagePositionInfoList>
	</view>
</template>
<script>
	import {
		storageGetEntityByCode,
	} from "@/api/homepage.js"
	import storagePositionInfoList from './InfoList/storagePositionInfoList.vue'
	export default {
		components: {
			storagePositionInfoList
		},
		data() {
			return {
				storagePosition: '',
				storagePositionInfoList: [],
			}
		},
		onPullDownRefresh() {
			setTimeout(function() {
				uni.redirectTo({
					url: "/pages/HomePage/StoreManagement/AccessoryManagement/InStorage/storagePositionList"
				})
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad() {
			//PDA扫描
			var _this = this
			uni.$on('scancodedate', function(data) {
				_this.searchList(data.code)
			})
		},
		onUnload() {
			// 移除监听事件      
			uni.$off('scancodedate')
		},
		methods: {
			searchList(e) {
				storageGetEntityByCode({
					code: e
				}).then((res) => {
					this.storagePositionInfoList = []
					if (res.code == 0) {
						let storagePositionGood = {
							stock: res.data.stock,
							warehouseStorageId: res.data.id,
							warehousePositionId: res.data.warehousePositionId,
							code: res.data.code,
							createTime: res.data.createTime,
						}
						this.storagePositionInfoList.push(storagePositionGood)
					} else {
						uni.$u.toast(res.message)
					}
				}).catch((res) => {
					uni.$u.toast(res.message)
				});
			},
		}
	}
</script>
<style lang="scss" scoped>
</style>